<?php

namespace App\Validate;

use App\Validate\BaseValidate;

/**
 * 验证器
 */
class SatisfactionSurveyValidate extends BaseValidate
{

    //验证规则
    protected $rule = [
        'id' => 'bail|required|integer',
        'survey_id' => 'bail|required|integer',
        'day_number' => 'bail|required|integer',
        'total_number' => 'bail|required|integer',
        'survey_name' => 'bail|required',
        'start_time' => 'required|date',
        'end_time' => 'required|date|after:start_time',
        'problem' => 'bail|required',
        'is_play' => 'bail|required|in:1,2',
        'type' => 'bail|required|in:1,2,3',
        'answers' => 'bail|required|json',
        'qr_code' => 'bail|required|size:10',

        'username' => 'required|min:2',
        'tel' => 'required|check_tel_and_phone:',
        'is_satisfaction' => 'bail|required|in:1,2',
    ];


    //自定义验证信息
    protected $message = [
        'id.required' => 'ID不能为空',
        'id.integer' => 'ID格式不正确',
        'survey_id.required' => '问卷ID不能为空',
        'survey_id.integer' => '问卷ID格式不正确',

        'day_number.required' => '每日可提交次数不能为空',
        'day_number.integer' => '每日可提交次数格式不正确',

        'total_number.required' => '总共可提交次数不能为空',
        'total_number.integer' => '总共可提交次数格式不正确',

        'survey_name.required' => '问卷名不能为空',
        "start_time.required" => "问卷开始时间不能为空",
        "start_time.date" => "问卷开始时间参数错误",
        "end_time.required" => "问卷结束时间不能为空",
        "end_time.date" => "问卷结束时间参数错误",
        "end_time.after" => "问卷结束时间不能小于开始时间",
        "problem.required" => "问题不能为空",
        "is_play.required" => "状态不能为空",
        "is_play.in" => "状态有误",
        "type.required" => "题目类型不能为空",
        "type.in" => "题目类型有误",
        "answers.required" => "答案不能为空",
        "answers.json" => "答案格式不正确",
        "qr_code.required" => "核销码不能为空",
        "qr_code.size" => "核销码格式不正确",

        "tel.required" => "电话号码不能为空",
        "tel.check_tel_and_phone" => "电话号码格式不正确",

        "username.required" => "用户姓名不能为空",
        "username.min" => "用户姓名格式不正确",
        "is_satisfaction.required" => "满意度不能为空",
        "is_satisfaction.in" => "满意度格式不正确",
    ];


    protected $scene = [
        // 问卷调查详情
        "detail" => ["id"],
        // 问卷调查 前台详情
        "web_detail" => ["id"],
        // 问卷调查 前台详情
        "wx_detail" => ["id"],

        // 问卷调查 前台提交满意度调查
        "wx_reply" => ["id", 'username', 'tel', 'is_satisfaction'],

        // 问卷调查添加
        "add" => ["survey_name", "start_time", 'end_time', 'day_number', 'total_number'],

        // 问卷调查修改
        "change" => ['id', "survey_name", "start_time", 'end_time', 'day_number', 'total_number'],

        // 问卷调查删除
        "del" => ["id"],

        //问卷调查回复列表
        "reply_list" => ["survey_id"],



        // 问卷调查 撤销  与 发布
        "cancelAndRelease" => ["id", 'is_play'],

        // 问卷调查 前台用户回复问题
        "apply" => ["id", 'answers'],




        //手动核销
        "hand_verification" => ['survey_id', "id"],

        //核销码进行核销
        "qr_code_verification" => ['survey_id', "qr_code"],
    ];
}
